package com.cxj;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;

import com.waps.AppConnect;
import com.waps.UpdatePointsNotifier;

public class AppDialog implements DialogInterface.OnClickListener, UpdatePointsNotifier {
    public static final String PRENAME = "cxjapps";
    private Activity activity;

    private AppDialog(Activity paramActivity) {
        this.activity = paramActivity;
    }

    public static void show(Activity paramActivity) {
        if (!paramActivity.getSharedPreferences("cxjapps", 0).getBoolean("passscore", false)) {
            AppDialog localAppDialog = new AppDialog(paramActivity);
            AppConnect.getInstance(paramActivity).getPoints(localAppDialog);
            new AlertDialog.Builder(paramActivity)
                    .setTitle("欢迎您使用本应用!")
                    .setMessage(
                            "您当前的积分不足100分，可以通过【免费赚积分】可以进入推荐下载列表，下载并安装软件获取更多积分!!!\n\n只要积分满100分，重新启动应用后就可以消除所有应用的提示信息!!!\n\n通过【更多应用】可以下载更多有趣应用!!!\n")
                    .setPositiveButton("更多应用", localAppDialog).setNegativeButton("继续", localAppDialog)
                    .setNeutralButton("免费赚积分", localAppDialog).show();
        }
    }

    @Override
    public void getUpdatePoints(String paramString, int paramInt) {
        if (paramInt >= 100) {
            SharedPreferences.Editor localEditor = this.activity.getSharedPreferences("cxjapps", 0).edit();
            localEditor.putBoolean("passscore", true);
            localEditor.commit();
        }
    }

    @Override
    public void getUpdatePointsFailed(String paramString) {
    }

    @Override
    public void onClick(DialogInterface paramDialogInterface, int paramInt) {
        if (paramInt != -1) {
            if (paramInt == -3)
                AppConnect.getInstance(this.activity).showOffers(this.activity);
        } else
            AppConnect.getInstance(this.activity).showMore(this.activity);
    }
}